{include file="header.tpl"}

	<h1>{if $project.id}Edit{else}Add{/if} Project</h1>

   {include file="admin_sidebar.tpl"}

   <div id="content">
   
      {include file="flashes.tpl"}

   	<form id="frm_project" action="" method="post">
   
   		<fieldset class="panel">
   			
   			<div>
   				<label for="description">Description:</label>
        			<input id="description" name="description" type="text" value="{$project.description}" />
        			{if $project.errors.description}<p class="error">{$project.errors.description}</p>{/if}
   	 		</div>
   			
   			{if $project.system_type}
   			<div>
   				<label for="system_type">System Type:</label>
        			<select id="system_type" name="system_type">
                  {foreach item=desc from=$system_types}
                  <option value="{$desc}"{if $desc == $project.system_type}{$spf.selected}{/if}>{$desc}</option>
                  {/foreach}
   				</select>
   	 		</div>
   	 		{/if}
      		
   			<div>
   				<label>Active:</label>
        			<div class="option">
        			   <label for="active_1" class="option"><input type="radio" id="active_1" name="active" value="1" {if $project.active}{$spf.checked}{/if} /> Yes</label>
        			</div>
        			<div class="option">
        			   <label for="active_0" class="option"><input type="radio" id="active_0" name="active" value="0" {if !$project.active}{$spf.checked}{/if} /> No</label>
        			</div>
   	 		</div>
   	 		
   		</fieldset>
   		
   		<div class="button_bar">
   			<button type="submit" name="submit_frm_project" value="1">Submit</button>or <a href="{$spf.base_url}/projects">Cancel</a>
   		</div>
   		
   	</form>
   	
      <div class="clear"></div>
      
      {if $project.id}
      <div id="project_components">
         <h3>Components</h3>
         <div class="action_bar">
            <a class="add" href="{$spf.base_url}/projects/edit_component/{$project.id}">Add</a>
         </div>
         <table rules="all" frame="box">
            <thead>
               <tr>
                  <th>Description</th>
                  <th class="center">Active</th>
                  <th class="center">Edit</th>
                  <th class="center">Delete</th>
               </tr>
            </thead>
            <tbody>
               {foreach item=component from=$components}
               <tr class="{cycle name=components values=",alt"}">
                  <td>{$component.description}</td>
                  <td class="center"><img src="img/{if $component.active}tick{else}cross{/if}.png" alt="" /></td>
                  <td class="edit"><a href="{$spf.base_url}/projects/edit_component/{$project.id}/{$component.id}"></a></td>
                  <td class="delete"><a href="#" onclick="spf.sitrack.confirm('/projects/delete_component/{$project.id}/{$component.id}')"></a></td>
               </tr>
               {/foreach}
               {if !$components}<tr><td class="norecords" colspan="10">No records found.</td></tr>{/if}
            </tbody>
         </table>
      </div>
      
      <div id="project_milestones">
         <h3>Milestones</h3>
         <div class="action_bar">
            <a class="add" href="{$spf.base_url}/projects/edit_milestone/{$project.id}">Add</a>
         </div>
         <table rules="all" frame="box">
            <thead>
               <tr>
                  <th>Description</th>
                  <th class="center">Active</th>
                  <th class="center">Edit</th>
                  <th class="center">Delete</th>
               </tr>
            </thead>
            <tbody>
               {foreach item=milestone from=$milestones}
               <tr class="{cycle name=milestones values=",alt"}">
                  <td>{$milestone.description}</td>
                  <td class="center"><img src="img/{if $milestone.active}tick{else}cross{/if}.png" alt="" /></td>
                  <td class="edit"><a href="{$spf.base_url}/projects/edit_milestone/{$project.id}/{$milestone.id}"></a></td>
                  <td class="delete"><a href="#" onclick="spf.sitrack.confirm('/projects/delete_milestone/{$project.id}/{$milestone.id}')"></a></td>
               </tr>
               {/foreach}
               {if !$milestones}<tr><td class="norecords" colspan="10">No records found.</td></tr>{/if}
            </tbody>
         </table>
      </div>
      {/if}
      
   </div>
   
{include file="footer.tpl"}
